<template>
	<view class="inv_records">
		<u-calendar v-model="show" mode="range" btn-type='success' range-color='#26C281' range-bg-color='rgba(38, 194, 129, 0.13)' active-bg-color='#26C281' :safe-area-inset-bottom='true' @change="change"></u-calendar>
		
		<view>
			<view class="w_money">
				<view class="header">
					<view class="header-left">
					<view class="title">总余额</view>
					<view class="money">
						<text>￥</text>{{all_money}}
					</view>
					</view>
					<view class="r-btn" @click="allBtn">提现</view>
				</view>
				<view class="footer">
					<view class="f_left">
						<view class="word">待打款</view>
						<view class="money">{{weidakuan}}<text>元</text></view>
					</view>
					<view class="f_right">
						<view class="word">累计提现</view>
						<view class="money">{{withdraw_money}}<text>元</text></view>
					</view>					
				</view>
			</view>
		</view>
		<view class="team_top">
			<view class="nav">
				<view class="left" @click="show=true">
					<text class="time" :class="startTime?'time_active':''">{{startTime?startTime:'开始时间'}}</text>
					<text class="line">-</text>
					<text class="time" :class="endTime?'time_active':''">{{endTime?endTime:'结束时间'}}</text>
				</view>
				<view class="right" @click="queryBtn">查询</view>
			</view>
			<view class="nav_list">
				<u-tabs :list="navList" height='88' active-color='#26C281' inactive-color='#222222' :is-scroll="false" :current="current" @change="navChange"></u-tabs>
			</view>
		</view>
		<view style="height: 120rpx;"></view>
		
		<!-- <view class="num_list">
			<view class="txt">
				<text class="t_num">12</text>
				<text class="t_tip">未发放</text>
			</view>
			<view class="txt">
				<text class="t_num">12</text>
				<text class="t_tip">已发放</text>
			</view>
		</view> -->
		<!--  -->
		<view class="no_html" v-if="list.length==0">
			<image src="@/static/images/no_img6.png" mode=""></image>
			<text>暂无明细</text>
		</view>
		<!--  -->
		<view v-else>	
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="text">
					<text class="left">{{item.memo}}</text>
					<text class="right">{{item.createtime_text}}</text>
				</view>
				<view class="text" v-if="item.goods_name_text">
					<text class="left" style="color: #999999;">{{item.goods_name_text}}</text>
					<text class="right" style="color: #999999;">{{item.phone_text}}</text>
				</view>
				<view class="text" style="color: #999999;" v-if="item.zhichu_text">
					<text class="left" style="color: #999999;">{{item.zhichu_text}}</text>
				</view>
				<view class="text">
					<text class="left" style="color: #999999;">变更金额：{{item.money}}</text>
					<text class="right color1">变更后：{{item.after}}</text>
					
				</view>
			</view>
			<view class="mall_loading" v-if="list.length" style="padding-top: 24rpx;">
				<u-loadmore :status="status" color='#999' />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				startTime:'',
				endTime:'',
				navList:[{
					name: '收入明细'
				}, {
					name: '支出明细'
				}],
				current: 0,
				id:'',
				info:'',
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				page: 1,
				list: [],
				all_money:'',
				weidakuan:'',
				withdraw_money:''
			};
		},
		onLoad(opt) {
			if(opt.id){
				this.id=opt.id
			}
		},
		onShow() {
			this.page=1
			this.getList()
		},
		methods:{
			// 列表
			getList() {
				var that = this
				if(that.page==1){
					that.$tips.showLoading('加载中')
				}else{
					that.status = 'loading'
				}
				var params = {
					page:that.page,
					sta_time: that.startTime,
					end_time: that.endTime,
					current:that.current
				}
				that.$httpApi.commissionLog(params).then((res) => {
					if (res.code == 1) {
						// that.info=res.data.info
						if (that.page == 1) {
							that.list = []
							that.$tips.hideLoading()
						}
						if (res.data.data.current_page == res.data.data.last_page) {
							that.status = 'nomore'
						} else {
							that.status = 'loadmore'
						}
						that.list = that.list.concat(res.data.data.data)
						that.all_money = res.data.all_money
						that.weidakuan = res.data.weidakuan
						that.withdraw_money = res.data.withdraw_money
					}
				})
			},
			// 查询
			queryBtn(){
				this.page=1
				this.getList()
			},
			// 切换
			navChange(index){
				this.current=index
				this.page=1
				this.getList()
			},
			// 选择日期
			change(e) {
				this.startTime=e.startDate
				this.endTime=e.endDate
			},
			allBtn(){
				uni.navigateTo({
					url:'/pages/shop/withdrawal'
				})
			},
		},
		onReachBottom() {
			if (this.status == 'nomore' || this.status == 'loading') {
				return
			}
			this.page++
			this.getList()
		},
	}
</script>

<style lang="less">
	.w_money{margin:20rpx;
			padding: 30rpx;
			background: #fff;
			border-radius: 20rpx;
			.header{
				display:flex;
				justify-content: space-between;
				padding:10rpx 0;
				align-items: center;
				.r-btn{border:1rpx solid #eee;padding:6rpx 20rpx;border-radius:6rpx;}
				
				.money{
					font-size:36rpx;
					font-weight:bold;
					text{font-size:24rpx;}
				}
			}
			.footer{
				display:flex;
				justify-content: center;
				align-items: center;
				padding:20rpx 0;
				.f_left{
					display:flex;
					justify-content: center;
					align-items: center;
					flex-direction: column;
					line-height:200%;
					width:300rpx;
					
					.money{
						font-size:36rpx;
						font-weight:bold;
						text{
							font-size:24rpx;
							font-weight:normal
						}
						
					}
					
					
					
				}
				.f_right{
					display:flex;
					justify-content: center;
					align-items: center;
					flex-direction: column;
					line-height:200%;
					width:300rpx;
					.money{
						font-size:36rpx;
						font-weight:bold;
						text{
							font-size:24rpx;
							font-weight:normal
						}
						
					}
					}
				}
				
			}
			
	.inv_records{
		width: 100%;
		.team_top{
			position: fixed;
			z-index: 10;
			width: 100%;
			background: #fff;
			border-bottom: 2rpx solid #f7f8fa;
			.nav{
				width: 100%;
				height: 100rpx;
				padding: 20rpx 32rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.left{
					width: 538rpx;
					height: 64rpx;
					padding: 0 30rpx;
					background: #F5F5F5;
					border-radius: 32rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;
					.line{
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #BEBEBE;
					}
					.time{
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #BEBEBE;
					}
					.time_active{
						color: #333;
					}
				}
				.right{
					width: 132rpx;
					height: 64rpx;
					line-height: 64rpx;
					text-align: center;
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					background: #26C281;
					border-radius: 32rpx;
				}
			}
			.nav_list{
				width: 100%;
				border-bottom: 2rpx solid #f7f8fa;
			}
		}
		.num_list{
			width: 100%;
			margin-bottom: 23rpx;
			padding: 24rpx 0;
			background: #fff;
			display: flex;
			justify-content: space-between;
			.txt{
				flex: 1;
				// width: 100%;
				border-left: 2rpx solid #f7f8fa;
				text{
					display: block;
					width: 100%;
					text-align: center;
				}
				.t_num{
					font-size: 32rpx;
					font-family: OPPOSans-Bold, OPPOSans;
					font-weight: bold;
					color: #222222;
				}
				.t_tip{
					padding-top: 8rpx;
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
			.txt:first-child{
				border-left: none;
			}
		}
		.list{
			width: 100%;
			margin-top: 80rpx;
			padding: 8rpx 32rpx 32rpx;
			background: #fff;
			.text{
				width: 100%;
				padding-top: 24rpx;
				display: flex;
				justify-content: space-between;
				.left{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #222222;
				}
				.right{
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				.color1{
					color: #FF6230;
				}
				.color2{
					color: #26C281;
				}
			}
		}
	}
</style>
